#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main()
{
	int n,m;
	cin>>n>>m;
	
	vector<vector<char>> arr(n,vector<char>(m));
    vector<vector<int>> vis(n,vector<int>(m));
	queue<pair<pair<int,int>,int>> q;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>arr[i][j];
			if(arr[i][j]=='k')
			{
				q.push({{i,j},0});
                vis[i][j]='1';
			}
		}
	}
	int ret=0x3f3f3f,cnt=0;
	while(q.size())
	{
        
		auto& [x,y]=q.front().first;
		
		int step=q.front().second;
		q.pop();
		for(int i=0;i<4;i++)
		{
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx<0 || nx>=n || ny<0 || ny>=m || vis[nx][ny] || arr[nx][ny]=='*')
				continue;
            vis[nx][ny]=1;
			if(arr[nx][ny]=='e')
			{

				cnt++;
				ret=min(ret,step+1);
			}
            else{
                q.push({{nx,ny},step+1});
            }
			
		}
	}	
	if(cnt==0)
	{
		cout<<"-1"<<endl;
	}
	else{
		cout<<cnt<<' '<<ret<<endl;
	}
	return 0;
}
